#include "Acceptor.h"
#include "TcpConnection.h"
#include <iostream>
using std::cout;
using std::endl;

void test0(){
    Acceptor acceptor("127.0.0.1",8888);
    acceptor.ready();

    //建立一条连接
    TcpConnection con(acceptor.accept());

    cout << con.toString() << " has connected! " << endl;

    while(1)
    {
        string msg = con.receive();
        cout << "recv msg from client: " << msg << endl;
        con.send("msg: " + msg);

        /* cout << "recv msg from client: " << con.receive() << endl; */
        /* con.send("hello world\n"); */
    }
}

int main(void){
    test0();
    return 0;
}

